package com.android.camera.one;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import com.android.camera.debug.Log;

import android.hardware.camera2.CaptureResult;

public class CaptureResultExtend {
	private static final Log.Tag TAG = new Log.Tag("CaptureResultExtend");
	
	private static Constructor mCaptureResultConstructor;
	
	private static void initialize() {
		if (mCaptureResultConstructor == null) {
			try {
	    		Class<?> nCaptureResultClass = Class.forName(CaptureResult.Key.class.getName());
	    		mCaptureResultConstructor = nCaptureResultClass.getConstructor(String.class, Class.class);
	    	} catch (Exception ex) {
	    		Log.d(TAG, ""+ex.toString());
	    	}
		}
	}	
	
	public static <T> CaptureResult.Key<T> getKey(String key, Class<T> clazz) 
			throws InstantiationException, IllegalAccessException, 
			IllegalArgumentException, InvocationTargetException {
		initialize();
		return (CaptureResult.Key<T>)mCaptureResultConstructor
				.newInstance(key, clazz);
	}
}
